Optimal. Leaf size=226 \[ \frac {(1-m) (A (1-m)-i B (1+m)) \, _2F_1\left (1,\frac {1+m}{2};\frac {3+m}{2};-\tan ^2(c+d x)\right ) \tan ^{1+m}(c+d x)}{4 a^2 d (1+m)}+\frac {(A (2-m)-i B m) \tan ^{1+m}(c+d x)}{4 a^2 d (1+i \tan (c+d x))}+\frac {m (i A (2-m)+B m) \, _2F_1\left (1,\frac {2+m}{2};\frac {4+m}{2};-\tan ^2(c+d x)\right ) \tan ^{2+m}(c+d x)}{4 a^2 d (2+m)}+\frac {(A+i B) \tan ^{1+m}(c+d x)}{4 d (a+i a \tan (c+d x))^2} \]
[Out]
________________________________________________________________________________________
Rubi [A]
time = 0.34, antiderivative size = 226, normalized size of antiderivative = 1.00, number of steps
used = 7, number of rules used = 4, integrand size = 34, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.118, Rules used = {3677, 3619,
3557, 371} \begin {gather*} \frac {(1-m) (A (1-m)-i B (m+1)) \tan ^{m+1}(c+d x) \, _2F_1\left (1,\frac {m+1}{2};\frac {m+3}{2};-\tan ^2(c+d x)\right )}{4 a^2 d (m+1)}+\frac {m (B m+i A (2-m)) \tan ^{m+2}(c+d x) \, _2F_1\left (1,\frac {m+2}{2};\frac {m+4}{2};-\tan ^2(c+d x)\right )}{4 a^2 d (m+2)}+\frac {(A (2-m)-i B m) \tan ^{m+1}(c+d x)}{4 a^2 d (1+i \tan (c+d x))}+\frac {(A+i B) \tan ^{m+1}(c+d x)}{4 d (a+i a \tan (c+d x))^2} \end {gather*}
Antiderivative was successfully verified.
[In]
[Out]
Rule 371
Rule 3557
Rule 3619
Rule 3677
Rubi steps
\begin {align*} \int \frac {\tan ^m(c+d x) (A+B \tan (c+d x))}{(a+i a \tan (c+d x))^2} \, dx &=\frac {(A+i B) \tan ^{1+m}(c+d x)}{4 d (a+i a \tan (c+d x))^2}+\frac {\int \frac {\tan ^m(c+d x) (a (A (3-m)-i B (1+m))-a (i A-B) (1-m) \tan (c+d x))}{a+i a \tan (c+d x)} \, dx}{4 a^2}\\ &=\frac {(A (2-m)-i B m) \tan ^{1+m}(c+d x)}{4 a^2 d (1+i \tan (c+d x))}+\frac {(A+i B) \tan ^{1+m}(c+d x)}{4 d (a+i a \tan (c+d x))^2}+\frac {\int \tan ^m(c+d x) \left (2 a^2 (1-m) (A (1-m)-i B (1+m))+2 a^2 m (i A (2-m)+B m) \tan (c+d x)\right ) \, dx}{8 a^4}\\ &=\frac {(A (2-m)-i B m) \tan ^{1+m}(c+d x)}{4 a^2 d (1+i \tan (c+d x))}+\frac {(A+i B) \tan ^{1+m}(c+d x)}{4 d (a+i a \tan (c+d x))^2}+\frac {(m (i A (2-m)+B m)) \int \tan ^{1+m}(c+d x) \, dx}{4 a^2}+\frac {((1-m) (A (1-m)-i B (1+m))) \int \tan ^m(c+d x) \, dx}{4 a^2}\\ &=\frac {(A (2-m)-i B m) \tan ^{1+m}(c+d x)}{4 a^2 d (1+i \tan (c+d x))}+\frac {(A+i B) \tan ^{1+m}(c+d x)}{4 d (a+i a \tan (c+d x))^2}+\frac {(m (i A (2-m)+B m)) \text {Subst}\left (\int \frac {x^{1+m}}{1+x^2} \, dx,x,\tan (c+d x)\right )}{4 a^2 d}+\frac {((1-m) (A (1-m)-i B (1+m))) \text {Subst}\left (\int \frac {x^m}{1+x^2} \, dx,x,\tan (c+d x)\right )}{4 a^2 d}\\ &=\frac {(1-m) (A (1-m)-i B (1+m)) \, _2F_1\left (1,\frac {1+m}{2};\frac {3+m}{2};-\tan ^2(c+d x)\right ) \tan ^{1+m}(c+d x)}{4 a^2 d (1+m)}+\frac {(A (2-m)-i B m) \tan ^{1+m}(c+d x)}{4 a^2 d (1+i \tan (c+d x))}+\frac {m (i A (2-m)+B m) \, _2F_1\left (1,\frac {2+m}{2};\frac {4+m}{2};-\tan ^2(c+d x)\right ) \tan ^{2+m}(c+d x)}{4 a^2 d (2+m)}+\frac {(A+i B) \tan ^{1+m}(c+d x)}{4 d (a+i a \tan (c+d x))^2}\\ \end {align*}
________________________________________________________________________________________
Mathematica [B] Both result and optimal contain complex but leaf count is larger than twice
the leaf count of optimal. \(565\) vs. \(2(226)=452\).
time = 4.40, size = 565, normalized size = 2.50 \begin {gather*} -\frac {i e^{-2 i c} \left (-\frac {i \left (-1+e^{2 i (c+d x)}\right )}{1+e^{2 i (c+d x)}}\right )^m \left (\frac {-1+e^{2 i (c+d x)}}{1+e^{2 i (c+d x)}}\right )^{-m} \left ((A+i B) e^{-4 i d x} \left (-1+e^{2 i (c+d x)}\right )^{1+m} \left (1+e^{2 i (c+d x)}\right )^{2-m}+e^{2 i (c-d x)} \left (-1+e^{2 i (c+d x)}\right )^{1+m} \left (1+e^{2 i (c+d x)}\right )^{2-m} (A (3-2 m)-i (B+2 B m))+\frac {2^{2-m} e^{4 i c} \left (-1+e^{2 i (c+d x)}\right )^{1+m} (A (-3+2 m)+i (B+2 B m)) \, _2F_1\left (-1+m,1+m;2+m;\frac {1}{2} \left (1-e^{2 i (c+d x)}\right )\right )}{1+m}+\frac {2^{1-m} e^{4 i c} \left (\frac {-1+e^{2 i (c+d x)}}{1+e^{2 i (c+d x)}}\right )^m \left (i B \left (-1+2 m^2\right )+A \left (1-4 m+2 m^2\right )\right ) \left (-2^m (1+m) \, _2F_1\left (1,m;1+m;\frac {1-e^{2 i (c+d x)}}{1+e^{2 i (c+d x)}}\right )+\left (1+e^{2 i (c+d x)}\right )^m \left ((1+m) \, _2F_1\left (m,m;1+m;\frac {1}{2} \left (1-e^{2 i (c+d x)}\right )\right )+\left (-1+e^{2 i (c+d x)}\right ) m \, _2F_1\left (m,1+m;2+m;\frac {1}{2} \left (1-e^{2 i (c+d x)}\right )\right )\right )\right )}{m (1+m)}\right ) \sec (c+d x) (\cos (d x)+i \sin (d x))^2 (A+B \tan (c+d x))}{16 d (A \cos (c+d x)+B \sin (c+d x)) (a+i a \tan (c+d x))^2} \end {gather*}
Warning: Unable to verify antiderivative.
[In]
[Out]
________________________________________________________________________________________
Maple [F]
time = 0.73, size = 0, normalized size = 0.00 \[\int \frac {\left (\tan ^{m}\left (d x +c \right )\right ) \left (A +B \tan \left (d x +c \right )\right )}{\left (a +i a \tan \left (d x +c \right )\right )^{2}}\, dx\]
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Maxima [F(-2)]
time = 0.00, size = 0, normalized size = 0.00 \begin {gather*} \text {Exception raised: RuntimeError} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Fricas [F]
time = 0.00, size = 0, normalized size = 0.00 \begin {gather*} \text {could not integrate} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Sympy [F]
time = 0.00, size = 0, normalized size = 0.00 \begin {gather*} - \frac {\int \frac {A \tan ^{m}{\left (c + d x \right )}}{\tan ^{2}{\left (c + d x \right )} - 2 i \tan {\left (c + d x \right )} - 1}\, dx + \int \frac {B \tan {\left (c + d x \right )} \tan ^{m}{\left (c + d x \right )}}{\tan ^{2}{\left (c + d x \right )} - 2 i \tan {\left (c + d x \right )} - 1}\, dx}{a^{2}} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Giac [F]
time = 0.00, size = 0, normalized size = 0.00 \begin {gather*} \text {could not integrate} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Mupad [F]
time = 0.00, size = -1, normalized size = -0.00 \begin {gather*} \int \frac {{\mathrm {tan}\left (c+d\,x\right )}^m\,\left (A+B\,\mathrm {tan}\left (c+d\,x\right )\right )}{{\left (a+a\,\mathrm {tan}\left (c+d\,x\right )\,1{}\mathrm {i}\right )}^2} \,d x \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________